package weibo

import (
	"github.com/crozz-net/gopenapi/request"
	"github.com/crozz-net/gopenapi/weibo/model/users"
	"net/url"
)

type api_user struct {
	client_id string
}

/**
 * 根据用户ID获取用户信息<br/>
 * http://open.weibo.com/wiki/2/users/show<br/>
 * 参数uid与screen_name二者必选其一，且只能选其一
 *
 * @param access_token access_token
 * @param uid          需要查询的用户ID
 * @param screen_name  需要查询的用户昵称
 */
func (this *api_user) Show(access_token, uid, screen_name string) (*users.Resp_show, error) {
	param := url.Values{}
	param.Add("access_token", access_token)
	param.Add("uid", uid)
	param.Add("screen_name", screen_name)

	obj := &users.Resp_show{}
	err := request.HttpGetAsObj(BASE_URL+"users/show.json", param, obj)

	return obj, err
}

/**
 * 通过个性化域名获取用户资料以及用户最新的一条微博<br/>
 * http://open.weibo.com/wiki/2/users/domain_show
 *
 * @param domain 需要查询的个性化域名。
 */
func (this *api_user) Domain_show(access_token, domain string) (*users.Resp_domain_show, error) {
	param := url.Values{}
	param.Add("access_token", access_token)
	param.Add("domain", domain)

	obj := &users.Resp_domain_show{}
	err := request.HttpGetAsObj(BASE_URL+"users/domain_show.json", param, obj)

	return obj, err
}

/**
 * 批量获取用户的粉丝数、关注数、微博数<br/>
 * http://open.weibo.com/wiki/2/users/counts
 *
 * @param uids 需要获取数据的用户UID，多个之间用逗号分隔，最多不超过100个
 */
func (this *api_user) Counts(access_token, uids string) (*users.Resp_counts, error) {
	param := url.Values{}
	param.Add("access_token", access_token)
	param.Add("uids", uids)

	obj := &users.Resp_counts{}
	err := request.HttpGetAsObj(BASE_URL+"users/counts.json", param, obj)

	return obj, err
}
